home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4251 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.1 KB  |  45 lines

  1. Path: aspentec.com!usenet
  2. From: Seb Rose <seb@hoboco.scotborders.co.uk>
  3. Newsgroups: comp.lang.c++,comp.os.ms-windows.nt.misc,comp.os.ms-windows.programmer.tools.mfc,comp.os.ms-windows.programmer.win32
  4. Subject: Re: MFC Extension DLL creation - different in VC++4?
  5. Date: Mon, 29 Jan 1996 09:49:17 +0000
  6. Organization: Aspen Technology, Inc.
  7. Message-ID: <310C981D.B75@hoboco.scotborders.co.uk>
  8. References: <822894063.29249@centa.demon.co.uk>
  9. NNTP-Posting-Host: bat.atuk.aspentec.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b3 (WinNT; I)
  14. CC: rose
  15.  
  16. I think the documentation for AfxGetInstanceHandle is wrong when 
  17. using MFC dynamically.
  18.  
  19. My solution is this:
  20.  
  21. class SwitchInstance
  22. {
  23.         HINSTANCE m_hAppInst;
  24.  
  25. public:
  26.         SwitchInstance()
  27.         {
  28.                 m_hAppInst = AfxGetResourceHandle();
  29.  
  30.                 AfxSetResourceHandle(theDll.m_hInstance);
  31.         }
  32.  
  33.         ~SwitchInstance()
  34.         {
  35.                 AfxSetResourceHandle(m_hAppInst);
  36.         }
  37. };
  38.  
  39.  
  40.  
  41. In each exported function I create an instance of 
  42. SwitchInstance.
  43.  
  44. Everything works - magic!
  45.